
package com.zsrt.day20170417.ch04;


public class AnimalDaoImpl implements AnimalDao{

	
	/**
	 * 添加一个动物
	 */
	@Override
	public boolean addAnimal(AnimalShop animalShop, Animal animal) {
		boolean flag = true;
		//从商店中拿到笼子
		
		Animal[] lz = animalShop.getLz();
		
		int count=0;
		//判断笼子是否满了
		for(int index=0;index<10;index++){
			//拿到第一个动物
			Animal dw = lz[index];
			
			if(dw != null){
				count++;
			}else{
				break;
			}
			
			
		}
		if(count<lz.length){
			lz[count] = animal;
		}else{
			flag= false; 
		}
 
		
		
		return flag;
	}

	
	
	

}
